/*
 * Copyright (C) 2010, JDevelopers (jdevelopers@my-pages.org) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
/**
 * 
 */
package org.jdevelopers.xarf;

import java.util.EnumSet;

/**
 * Enum for the content type of the attachment in a x-arf report.
 * 
 * @author Marcel Hartwig
 * @version 0.2
 * @since JXarfValidator 0.1
 */
public enum EXarfReportAttachmentType {
	
	/**
	 * Represents an attachment of the type text/plain.
	 */
	TEXT_PLAIN("text/plain"),
	
	/**
	 * Represents an attachment of the type message/rfc822.
	 */
	MESSAGE_RFC822("message/rfc822"),
	
	/**
	 * Represents no attachment (no attachment is attached).
	 */
	NONE("none"),
	
	/**
	 * It is not specified, from which type the attachment is.
	 */
	NOT_SPECIFIED("not-specified");
	
	String type;
	
	/**
	 * Constructor for the EXarfReportAttachmentType.
	 * 
	 * @param type name for the EXarfReportAttachmentType.
	 */
	private EXarfReportAttachmentType(String type) {
		this.type = type;
	}
	
	/**
	 * Returns the name for EXarfReportAttachmentType.
	 * 
	 * @return the name for EXarfReportAttachmentType.
	 */
	public String getType() {
		return type;
	}
	
	/**
	 * Provides the String representation of the <code>EXarfReportAttachmentType</code>.
	 */
	@Override
	public String toString() {
		return type;
	}
	
	/**
	 * Returns the associated EXarfReportAttachmentType from the given name. If the name does not match a 
	 * possible value, NOT_SPECIFIED will be returned.
	 * 
	 * @param enumName the name for EXarfReportAttachmentType you want to get.
	 * @return the associated EXarfReportAttachmentType.
	 */
	public static EXarfReportAttachmentType getByValue(String enumName){
		for (final EXarfReportAttachmentType element : EnumSet.allOf(EXarfReportAttachmentType.class)) {
            if (element.toString().equals(enumName)) {
                return element;
            }
        }
        return NOT_SPECIFIED;
    }
	
}
